package org.cskt.sl.sys.test;

import java.util.List;

import org.cskt.sl.sys.entity.Dictionary;
import org.cskt.sl.sys.entity.Goods;
import org.cskt.sl.sys.example.GoodsExample;
import org.cskt.sl.sys.service.DictionaryService;
import org.cskt.sl.sys.service.GoodsService;
import org.cskt.sl.util.Pager;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Demo {

	@Test
	public void test() {
		ApplicationContext ctx=new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml","applicationContext-sys.xml"});
		GoodsService goodsService=ctx.getBean(GoodsService.class);
		GoodsExample goodsExample=new GoodsExample();
		Pager pager=new Pager();
		pager.setPageSize(2);
		pager.setTotalCount(goodsService.countByExample(null));
		pager.setCurrentPage(1);
		List<Goods> list=goodsService.findGoodsPageList(goodsExample, pager);
		for (Goods goods : list) {
			System.out.println(goods.getGoodsname());
		}
		/*Goods goods=goodsService.getGoodsById(1);
		System.out.println(goods.getGoodsname());*/
	}
	

	@Test
	public void test01() {
		ApplicationContext ctx=new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml","applicationContext-sys.xml"});
		DictionaryService dictionaryService=ctx.getBean(DictionaryService.class);
		Dictionary dictionary=dictionaryService.getDictionaryById(7);
		System.out.println(dictionary.getName());
	}

}
